package com.traveldream.entities;

import java.io.Serializable;

import javax.persistence.*;

import java.util.Date;


/**
 * The persistent class for the hotel database table.
 * 
 */
@Entity
@NamedQueries({
	@NamedQuery(name="Hotel.findAll", query="SELECT h FROM Hotel h"),
	@NamedQuery(name="Hotel.findByPlace",query="SELECT h FROM Hotel h WHERE h.product.place.name LIKE :placeName"),
	@NamedQuery(name="Hotel.findBeetwenDates",query="SELECT h FROM Hotel h WHERE (h.checkInDate > :start AND h.checkOutDate < :end)"),
	@NamedQuery(name="Hotel.findByStartingDate",query="SELECT h FROM Hotel h WHERE h.checkInDate > :start"),
	@NamedQuery(name="Hotel.findByEndingDate",query="SELECT h FROM Hotel h WHERE h.checkOutDate < :end"),
	@NamedQuery(name="Hotel.findBeetwenDatesByPlace",query="SELECT h FROM Hotel h WHERE (h.checkInDate > :start AND h.checkOutDate < :end) AND h.product.place.name LIKE :placeName")
})

public class Hotel implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="product_id",insertable=false,updatable=false)
	private int productId;

	@Temporal(TemporalType.DATE)
	@Column(name="check_in_date")
	private Date checkInDate;

	@Temporal(TemporalType.DATE)
	@Column(name="check_out_date")
	private Date checkOutDate;

	private String description;

	private String name;

	private int stars;

	//bi-directional one-to-one association to Product
	@OneToOne
	private Product product;

	public Hotel() {
	}

	public int getProductId() {
		return this.productId;
	}

	public void setProductId(int productId) {
		this.productId = productId;
	}

	public Date getCheckInDate() {
		return this.checkInDate;
	}

	public void setCheckInDate(Date checkInDate) {
		this.checkInDate = checkInDate;
	}

	public Date getCheckOutDate() {
		return this.checkOutDate;
	}

	public void setCheckOutDate(Date checkOutDate) {
		this.checkOutDate = checkOutDate;
	}

	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getStars() {
		return this.stars;
	}

	public void setStars(int stars) {
		this.stars = stars;
	}

	public Product getProduct() {
		return this.product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}
	
	@Override
	public boolean equals(Object obj) {
	    if(this.productId == ((Hotel) obj).productId) {
	        return true;
	    }else {
	        return false;
	    }
	}

}